
import {reqCategoryList,reqGetBannerList,reqGetFloorList} from '@/api'
//存储数据
const state = {
    categoryList:[],
    bannerList:[],
    floorList:[],

};
//书写业务逻辑
const actions = {
   //注意：参数要传递commit 
   async categoryList({ commit }){
       let result = await reqCategoryList();
       if (result.code==200){
            commit("CATEGORYLIST",result.data);
       }
    },
    async getBannerList({ commit }){
        let result = await reqGetBannerList();
        if (result.code==200){
            commit("GETBANNERLIST",result.data);
        }
     }, 
     async getFloorList({ commit }){
        let result = await reqGetFloorList();
        if (result.code==200){
            commit("GETFLOORLIST",result.data);
        }
     }
};
//修改state
const mutations = {
    CATEGORYLIST(state,categoryList){
        state.categoryList = categoryList;
    },
    GETBANNERLIST(state,bannerList){
        state.bannerList = bannerList;
    },
    GETFLOORLIST(state,bannerList){
        state.floorList = bannerList;
    }
};
//getters相当于计算属性，用于简化仓库数据
const getters = {};

export default {
    state,
    actions,
    mutations,
    getters,
}